
/**
 * api分析来自 
 * https://myzhbit.cn/microHelper/web/index.php
 */


let Util = getApp().Util;
let Config = getApp().Config;

export default class API {


    /**
    * 获得成绩
    */
    static getScore(term, number, password) {
        return Util.NET.postJson(`${Config.HOST}?r=score/index`, { type: 'checkScore', term: term, number: number, password: password });
    }

    /**
    * 获得成绩参数
    */
    static getScoreConfig() {
        return Util.NET.postJson(`${Config.HOST}?r=score/config`, {});
    }


    /**
    * 获得考试
    */
    static getExam(term, number, password) {
        return Util.NET.postJson(`${Config.HOST}?r=exam/index`, { type: 'checkExam', term: term, number: number, password: password });
    }

    /**
    * 获得考试参数
    */
    static getExamConfig() {
        return Util.NET.postJson(`${Config.HOST}?r=exam/config`, {});
    }

    /**
    * 获得课表
    */
    static getSchedule(week, number, password) {
        return Util.NET.postJson(`${Config.HOST}?r=schedule/index`, { type: 'checkSchedule', term: '2016-2017-2', week: week, number: number, password: password });
    }

    /**
    * 获得课表参数
    */
    static getScheduleConfig() {
        return Util.NET.postJson(`${Config.HOST}?r=schedule/config`, {});
    }


    /**
    * 获得校内电话
    */
    static getCampusTel() {
        return Util.NET.postJson(`${Config.HOST}?r=campustel/wechatlist`, { type: 'campusTel' });
    }

    /**
    * 获得学生教务信息
    */
    static getStInfo(number, password) {
        return Util.NET.postJson(`${Config.HOST}?r=user/index`, { type: 'checkStInfo', number: number, password: password });
    }


    /**
    * 解绑
    */
    static unbind(openId) {
        return Util.NET.postJson(`${Config.HOST}?r=user/unbind`, { openId: openId });
    }



    /**
     * 绑定
     */
    static bind(openId, number, password) {
        return Util.NET.postJson(`${Config.HOST}?r=user/bind`, { openId: openId, number: number, password: password });
    }


    /**
     * 获取文章列表
     */
    static getArticles(page) {
        return Util.NET.postJson(`${Config.HOST}?r=article/wechatlist`, { page: page });
    }

    /**
     * 获取文章内容
     */
    static getArticle(id) {
        return Util.NET.postJson(`${Config.HOST}?r=article/getarticlebyid`, { id: id });
    }



    /**
     * 上传文件
     */
    static uploadFile(filePath) {
        return Util.NET.uploadFile(`${Config.HOST}?r=community/uploadpic`, filePath, 'UploadFileForm[file]', {});
    }


    /**
     * 社区填写
     */
    static postCommunity(openId, nickName, avatarUrl, content, images, contactWay, contact, type) {
        return Util.NET.postJson(`${Config.HOST}?r=community/add`, { openId: openId, nickName: nickName, avatarUrl: avatarUrl, content: content, images: images, contactWay: contactWay, contact: contact, type: type });
    }




    /**
     * 全部
     */
    static getAllCommunity(page) {
        return Util.NET.postJson(`${Config.HOST}?r=community/wechatlist`, { type: '-1', page: page });
    }

    /**
      * 失物招领
      */
    static getLostCommunity(page) {
        return Util.NET.postJson(`${Config.HOST}?r=community/wechatlist`, { type: '0', page: page });
    }

    /**
     * 二手闲置
     */
    static getBuyCommunity(page) {
        return Util.NET.postJson(`${Config.HOST}?r=community/wechatlist`, { type: '1', page: page });
    }

    /**
     * 吐槽专区
     */
    static getChatCommunity(page) {
        return Util.NET.postJson(`${Config.HOST}?r=community/wechatlist`, { type: '2', page: page });
    }

    /**
     * 搜索
     */
    static getCommunitySearch(content) {
        return Util.NET.postJson(`${Config.HOST}?r=community/wechatsearch`, { content: content });
    }

}

